package com.lutzyt.delivery.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lutzyt.delivery.bean.req.Action;
import com.lutzyt.delivery.service.ActionService;
import com.lutzyt.delivery.service.AuditService;
import com.lutzyt.delivery.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * @Author: zyt
 */
public class ActionAuditController<S1 extends ActionService<T>,S2 extends AuditService<T>,T> {
  @Autowired
  protected S1 actionService;

  @PostMapping("/action")
  public Result<Void> action(@RequestBody Action action) {
    actionService.action(action);
    return Result.success();
  }

  @Autowired
  protected S2 auditService;

  @PostMapping("/audit/page")
  public Result<Page<T>> auditPage(Integer pageSize, Integer pageNum){
    final Page<T> page = auditService.auditPage(pageNum, pageSize);
    return Result.success(page);
  }
  @PutMapping("/{id}/audit/pass")
  public Result<Void> pass(@PathVariable String id){
    auditService.pass(id);
    return Result.success();
  }

  @PutMapping("/{id}/audit/noPass")
  public Result<Void> noPass(@PathVariable String id){
    auditService.noPass(id);
    return Result.success();
  }
}
